import myAxios from "@/request/myAxios.ts";

// 获取当前用户信息
export const getCurrentUser = async () => {
    return await myAxios.get('/user/current')
}


// 更新用户信息
export const setCurrentUser = async (userId:string,editUser:(number | string)[]) => {
    return  await myAxios.put('/user/update',{
        id: userId,
        [editUser[0] as string]:editUser[1],
    })
}

// 修改头像
export const setAvatar = (formData:FormData) => {
    return myAxios.post('/common/upload',formData,{
        headers:{
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 用户创建的队伍
export const getUserTeamCreate = async (val:string,currentPage:number) => {
    return await myAxios.get('/team/list/my/create',{
        params: {
            searchText: val,
            currentPage
        }
    })
}

// 用户加入的队伍
export const getUserTeamJoin = async (val:string,currentPage:number) => {
    return await myAxios.get('/team/list/my/join',{
        params: {
            searchText: val,
            currentPage
        }
    })
}

// 用户发布的博文
export const getUserBlogList = (currentPage:number) => {
    return myAxios.get('/blog/list/my/blog',{
        params: {
            currentPage
        }
    })
}

// 用户标签更新
export const getUserTags = async () => {
    return await myAxios.get('/user/tags')
}
export const updateTags = async (tags:Array<string>) => {
    return await myAxios.put('/user/update/tags',tags)
}

// 根据id获取用户详情
export const getUserDetail = async (id:string) => {
    return await myAxios.get('/user/'+id)
}

// 关注用户
export const setFollow = async (id:string) => {
    return await myAxios.post('/follow/'+id)
}
